#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=4e2+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL fac[maxn];
LL dp[maxn][maxn];
LL c[maxn][maxn];
LL n,mod;
void pre(){
     c[0][0]=1;
     for(LL i=1;i<maxn;i++){
         for(LL j=0;j<=i;j++){
             c[i][j]=(c[i-1][j-1]%mod+c[i-1][j]%mod)%mod;
         }
     }
}
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   cin>>n>>mod;
   fac[0]=1;
   for(LL i=1;i<maxn;i++) fac[i]=fac[i-1]*2%mod;
   pre();
   dp[0][0]=1;
   for(LL len=0;len<=n;len++){
       for(LL cnt=0;cnt<=len;cnt++){
           for(LL k=1;len+k<=n;k++){
               dp[len+k+1][cnt+k]+=( ( (dp[len][cnt]%mod*fac[k-1]%mod)%mod*c[cnt+k][k])%mod)%mod;
           }
       }
   }
   LL ans=0;
   for(LL cnt=0;cnt<=n;cnt++){
       ans=(ans%mod+dp[n+1][cnt]%mod)%mod;
   }
   cout<<ans<<"\n";
   return 0;
}
